package com.ruoyi.system.controller.logistics;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.Foodinfo;
import com.ruoyi.system.service.IFoodinfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 伙食信息汇总Controller
 *
 * @author ruoyi
 * @date 2023-12-27
 */
@RestController
@RequestMapping("/foodInfo")
public class FoodinfoController extends BaseController
{
    @Autowired
    private IFoodinfoService foodinfoService;

    /**
     * 查询伙食信息汇总列表
     */
    @RequiresPermissions("system:foodInfo:list")
    @GetMapping("/list")
    public TableDataInfo list(Foodinfo foodinfo)
    {
        startPage();
        List<Foodinfo> list = foodinfoService.selectFoodinfoList(foodinfo);
        return getDataTable(list);
    }

    /**
     * 导出伙食信息汇总列表
     */
    @RequiresPermissions("system:foodInfo:export")
    @Log(title = "伙食信息汇总", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Foodinfo foodinfo)
    {
        List<Foodinfo> list = foodinfoService.selectFoodinfoList(foodinfo);
        ExcelUtil<Foodinfo> util = new ExcelUtil<Foodinfo>(Foodinfo.class);
        util.exportExcel(response, list, "伙食信息汇总数据");
    }

    /**
     * 获取伙食信息汇总详细信息
     */
    @RequiresPermissions("system:foodInfo:query")
    @GetMapping(value = "/{MealID}")
    public AjaxResult getInfo(@PathVariable("MealID") Long MealID)
    {
        return success(foodinfoService.selectFoodinfoByMealID(MealID));
    }

    /**
     * 新增伙食信息汇总
     */
    @RequiresPermissions("system:foodInfo:add")
    @Log(title = "伙食信息汇总", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Foodinfo foodinfo)
    {
        return toAjax(foodinfoService.insertFoodinfo(foodinfo));
    }

    /**
     * 修改伙食信息汇总
     */
    @RequiresPermissions("system:foodInfo:edit")
    @Log(title = "伙食信息汇总", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Foodinfo foodinfo)
    {
        return toAjax(foodinfoService.updateFoodinfo(foodinfo));
    }

    /**
     * 删除伙食信息汇总
     */
    @RequiresPermissions("system:foodInfo:remove")
    @Log(title = "伙食信息汇总", businessType = BusinessType.DELETE)
	@DeleteMapping("/{MealIDs}")
    public AjaxResult remove(@PathVariable Long[] MealIDs)
    {
        return toAjax(foodinfoService.deleteFoodinfoByMealIDs(MealIDs));
    }
}
